#!/bin/bash
export CODER_DATA=$HOME/.config/coderv2-docker
export DOCKER_GROUP=$(getent group docker | cut -d: -f3)
mkdir -p $CODER_DATA
docker run -itd \
    --name coder \
    -e CODER_PG_CONNECTION_URL="postgres://postgres:19920216hjx@192.168.31.100:5432/coder?sslmode=disable" \
    -e CODER_ACCESS_URL="http://192.168.31.100:8000" \
    -e CODER_HTTP_ADDRESS="0.0.0.0:8000" \
    -e CODER_TLS_ENABLE="false" \
    -v $CODER_DATA:/home/coder/.config \
    -v /run/docker.sock:/var/run/docker.sock \
    --group-add $DOCKER_GROUP \
    -p 8000:8000 \
    --restart always \
    ghcr.io/coder/coder:latest
